﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using V5_Model;
using V5_Common;
using System.Data;
using V5_BLL;

namespace V5_EShop._Template.Default
{
    public partial class product_allask : BasicPage
    {
        public ModelProduct product = new ModelProduct();
        public ModelProductAsk m_productask = new ModelProductAsk();
        int proid = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                proid = Input.SetInt(Request["productid"]);
                if (proid > 0)
                {
                    Bind_rpList();
                    product = new BLLProduct().GetModel(proid);
                }
            }
        }
        //绑定问题列表
        private void Bind_rpList()
        {
            string strWhere = "";
            int count = 0;
            if (proid > 0)
            {
                strWhere = " ProductID=" + proid+" And Passed=1 ";
            }
            DataTable dt = new BLLProductAsk().GetList(Pager.PageSize, Pager.CurrentPageIndex,
                strWhere,
                ref count).Tables[0];
            this.rpList.DataSource = dt;
            this.rpList.DataBind();
        }

        /// <summary>
        /// 返回回答总数
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public int Get_AskCount(object o)
        {
            int id = Input.SetInt(o);
            if (id > 0)
            {
                return new BLLProductAnswer().GetList(" AskID=" + id).Tables[0].Rows.Count;
            }
            return 0;
        }

        protected void Pager_PageChanged(object sender, EventArgs e)
        {
            Bind_rpList();
        }
    }
}
